package test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cc.geguol.scm.entity.Account;
import cc.geguol.scm.entity.Supplier;
import cc.geguol.scm.service.AccountService;
import cc.geguol.scm.service.SupplierService;
import static org.junit.Assert.assertEquals;

/**
 * 作者  Administrator
 * 时间  2017/5/5 9:20
 * 文件  Scm
 * 描述
 */
public class Main {
	//@Resource //这里没法使用，后继版本有其它方式可以注入
	static private SupplierService supplierService;
	static private AccountService accountService;
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		ApplicationContext context =new ClassPathXmlApplicationContext("applicationContext.xml");
		supplierService=(SupplierService) context.getBean("supplierService");
		accountService=(AccountService) context.getBean("accService");
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {

	}

	@Test
	public void testSelectDept() throws Exception {
		if (supplierService != null) {
			System.out.println("加载正常");
		}
		Supplier popj=new Supplier("天津养猪场","15011421542");
//		popj.setSupId(2);
		popj.setSupRemark("一级供应商");
		popj.setSupAddress("旺达通14");
		popj.setSupLinkman("LadyGaga15");
//		System.out.println("获取的id："+supplierService.insert(popj));
		supplierService.insert(popj);
		assertEquals(Integer.valueOf(11),popj.getSupId());
	}

	@Test
	public void testInsertDept() throws Exception {

		Account account=new Account("Geguo","1982");
		System.out.println("受影响行数："+accountService.insertAcc(account));
	}
}

